# 选择排序，每次遍历找到最大值

def selectSort(alist):
    for fillslot in range(len(alist)-1,0,-1):
        positionOfMax = 0
        for i in range(1,fillslot+1):
            if alist[i] > alist[positionOfMax]:
                positionOfMax = i

        temp = alist[fillslot]
        alist[fillslot] = alist[positionOfMax]
        alist[positionOfMax] = temp


if __name__ == '__main__':
    alist = [54, 26, 93, 17, 77, 31, 44, 55, 20]
    selectSort(alist)
    print(alist)